<div class="config-container">
<h3>Environment Variables</h3>
<span title="Environment variables defined here are set on the agents and can be used within your tasks. <a class='' href='<%= docs_url '/faq/dev_use_current_revision_in_build.html' %>' target='_blank'>More...</a>" class="contextual_help has_go_tip_right">&nbsp;</span>
<%= render :partial => "admin/shared/global_errors.html", :locals => {:scope => {}} -%>
<%= form_for(@stage,
             :as => :stage,
             :url => admin_stage_update_path,
             :html => {:method => "PUT",
                       :id => "stage_edit_form",
                       :onsubmit => "return AjaxForm.jquery_ajax_submit(this, AjaxForm.ConfigFormEditHandler);",
                       :class => "popup_form"}) do |f| %>

    <%= hidden_field_tag :pipeline_digest, @pipeline_digest %>
    <%= hidden_field_tag :pipeline_group_name, @pipeline_group_name %>
    <%= hidden_field_tag :pipeline_name, @pipeline.name %>

    <%= render partial: 'admin/shared/environment_variable_fieldset', locals: {
                                                                            form: f,
                                                                            collection: @stage.getPlainTextVariables(),
                                                                            collection_name: :variables,
                                                                            nested_name: 'stage>variables',
                                                                            read_only_page: @is_config_repo_pipeline
                                                                    } %>


    <h3>Secure Variables</h3>
    <span title="Environment variables that are never displayed or logged in plain text. <a class='' href='<%= docs_url '/faq/dev_use_current_revision_in_build.html' %>' target='_blank'>More...</a>" class="contextual_help has_go_tip_right">&nbsp;</span>
    <div class="fieldset">
        <%= render :partial => "admin/shared/name_value", :locals => {:scope => {:form => f, :collection => @stage.getSecureVariables(), :collection_name => :variables, :secure => true, read_only_page: @is_config_repo_pipeline}} %>
        <div class='clear'></div>
    </div>

    <%= render :partial => "admin/shared/form_submit", :locals => {:scope => {:reset_url => admin_stage_edit_path(:pipeline_name => @pipeline.name(), :stage_name => params[:stage_name], :current_tab => "environment_variables")}} unless @is_config_repo_pipeline %>
    <%= render :partial => 'shared/convert_tool_tips.html', :locals => {:scope => {}} %>
<% end %>
</div>
<script type="text/javascript">
    AjaxForm.error_box_selector = '#form_parent';
</script>
